<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改服务区域</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__CSS__/animate.min.css" rel="stylesheet">
    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="__CSS__/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__JS__/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css" rel="stylesheet">
    <link href="__JS__/layui/css/layui.css"rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-10">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改服务区域</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="commentForm" method="post" action="{:url('quyu')}">
                        <input type="hidden" name="id" value="{$id}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">已选择的服务区域：</label>
                            <div class="input-group col-sm-4">
                                {foreach $old as $v}
                                <span>{$v}</span>
                                {/foreach}
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">服务地址：</label>
                            <div class="input-group col-sm-4">
                                <select class="form-control" name="province" required="" id="province" onchange="getcity(this)" aria-required="true" style="width: 30%;">
                                    <option value="">请选择</option>
                                </select>
                                <select class="form-control" name="city" required=""  id="city" onchange="getcounty(this)" aria-required="true" style="width: 30%;float: left;margin-left: 3px">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">已选择的服务区域：</label>
                            <div class="input-group col-sm-4"  id="county">

                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-8">
                                <!--<input type="button" value="提交" class="btn btn-primary" id="postform"/>-->
                                <button class="btn btn-primary" type="submit">确认提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
<script src="__JS__/jquery.min.js?v=2.1.4"></script>
<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
<script src="__JS__/content.min.js?v=1.0.0"></script>
<script src="__JS__/plugins/bootstrap-tagsinput/bootstrap-tagsinput.min.js"></script>
<script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
<script src="__JS__/plugins/validate/messages_zh.min.js"></script>
<script src="__JS__/plugins/iCheck/icheck.min.js"></script>
<script src="__STATIC__/admin/laydate/laydate.js"></script>
<script src="__JS__/layui/layui.js"></script>
<script src="__JS__/jquery.form.js"></script>
<script type="text/javascript">
    laydate.render({
        elem: '#servcietime',
        type: 'datetime',
        format:'yyyy-MM-dd HH:mm'
    });
    var index = '';
    function showStart(){
        index = layer.load(0, {shade: false});
        return true;
    }

    function showSuccess(res){

        layer.ready(function(){
            layer.close(index);
            if(1 == res.code){
                layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
                    window.location.href = res.data;
                });
            }else if(111 == res.code){
                window.location.reload();
            }else{
                layer.msg(res.msg, {anim: 6});
            }
        });
    }

    $(document).ready(function(){

        // 添加角色
        var options = {
            beforeSubmit:showStart,
            success:showSuccess
        };

        $('#commentForm').submit(function(){
            $(this).ajaxSubmit(options);
            return false;
        });


        // 上传图片
        layui.use('upload', function(){
            var upload = layui.upload;

        });
        $.ajax({
            url:"{:url('order/ajxgetprovince')}",
            success:function (res) {
                $('#province').html(res);
            }
        })

    });

    var getcity = function(that){
        var province = $(that).val()
        $.ajax({
            url:"{:url('order/ajxgetcity')}",
            data:{province:province},
            success:function (res) {
                $('#city').html(res);

            }
        })
    }
    var getcounty = function(that){
        var province = $(that).val();
        var id = $('input[name="id"]').val();
        $.ajax({
            url:"{:url('ajxgetcity')}",
            data:{province:province,id:id},
            success:function (res) {
                console.log(res)
                $('#county').prepend(res);
                $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
            }
        })
    }
    // 表单验证
    $.validator.setDefaults({
        highlight: function(e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function(e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function(e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });
</script>
</body>
</html>
